#include "widget.h"
#include "ui_widget.h"

#include <QScrollArea>
#include <QPushButton>
#include <QVBoxLayout>
#include <QDebug>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    QScrollArea* scrollArea = new QScrollArea(this);
    scrollArea->resize(150, 250);
    scrollArea->move(250, 40);

    QWidget* w = new QWidget;
    QVBoxLayout* v = new QVBoxLayout(w);

    for (int i = 1; i <= 10; i++)
    {
        auto* btn = new QPushButton(QString("btn%1").arg(i));
        v->addWidget(btn);
        connect(btn, &QPushButton::clicked, [i](){
            qDebug() << i;
        });
    }
    scrollArea->setWidget(w);
}

Widget::~Widget()
{
    delete ui;
}
